<?php 
class product_plugin_discounts extends abstract_product_plugin {
 
    public function getProductDiscounts($product_id) {
		
		$query = $this->pdo->prepare("SELECT * FROM " . $this->db_prefix . "product_discount 
            WHERE product_id = :product_id
            AND user_group_id = :user_group_id  
            AND quantity > 1 
            AND ((date_start = '0000-00-00' OR date_start < NOW()) 
            AND (date_end = '0000-00-00' OR date_end > NOW()))  
            ORDER BY quantity ASC, priority ASC, price ASC");

		$query->execute(array(
            ':product_id'           => $product_id,
            ':user_group_id'    => $this->user_group_id,
        ));

		return $query->fetchAll(PDO::FETCH_ASSOC);
	}
}
